package org.xiaov.lunasql.parser;

import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLStatement;

/**
 * <p>
 * DruidParser
 * </p>
 *
 * @author lzq
 * @since 2024/12/11 10:33
 */
public class DruidParser {
    /**
     * 转换sql
     *
     * @param sql sql
     * @return SQLStatement
     */
    public SQLStatement parseSql(String sql) {
        SQLStatement sqlStatement = SQLUtils.parseSingleMysqlStatement(sql);
        LunaMySqlASTVisitorAdapter lunaMySqlASTVisitorAdapter = new LunaMySqlASTVisitorAdapter();
        sqlStatement.accept(lunaMySqlASTVisitorAdapter);
        return sqlStatement;
    }

}
